package com.zhongyu.controller;

import com.zhongyu.pojo.OrderDetail;
import com.zhongyu.pojo.Store;
import com.zhongyu.pojo.StoreDetail;
import com.zhongyu.service.StoreDetailService;
import com.zhongyu.service.StoreOperService;
import com.zhongyu.service.StoreService;
import com.zhongyu.vo.PageResult;
import com.zhongyu.vo.ResultVo;
import com.zhongyu.vo.StoreOperVo;
import com.zhongyu.vo.UserVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/kucun/store/")
public class KuCunController {
    @Resource
    private  StoreDetailService storeDetailService;
    @Resource
    private StoreService storeService;
    @Resource
    private StoreOperService storeOperService;
    @GetMapping("/list/{pageNo}/{pageSize}")
    public ResultVo list(@PathVariable Integer pageNo, @PathVariable Integer pageSize, StoreOperVo storeOperVo){
        PageResult pageResult= storeDetailService.searchAll(pageNo, pageSize, storeOperVo);
        return ResultVo.success(pageResult);
    }
    @GetMapping("/list")
    public ResultVo list(){
        List<Store> list= storeService.searchAll();
        return ResultVo.success(list);
    }
    @GetMapping("/oper/{pageNo}/{pageSize}")
    public ResultVo oper(@PathVariable Integer pageNo, @PathVariable Integer pageSize, StoreOperVo storeOperVo){
        PageResult pageResult = storeOperService.searchAll(pageNo, pageSize, storeOperVo);
        return ResultVo.success(pageResult);

    }
    @GetMapping("/goods")
    public ResultVo goods(){
        List<StoreDetail> storeDetailList=storeDetailService.searchGoods();
        return ResultVo.success(storeDetailList);
    }
    @GetMapping("storeId")
    public ResultVo storeId(Integer goodId){
        System.out.println(goodId);
        List< StoreDetail> list=storeDetailService.serachStoreId(goodId);
        System.out.println(list);
        return ResultVo.success(list);
    }
}
